﻿using SqlSugar;

namespace Benefactor.Models.DbModels;

[SugarTable("eb_product")]
public class CrmebProduct
{
    [SugarColumn(ColumnName = "id", IsIdentity = true, IsPrimaryKey = true)]
    public int Id { get; set; }

    [SugarColumn(ColumnName = "mer_id", IsNullable = false)]
    public int MerchantId { get; set; }

    [SugarColumn(ColumnName = "name", IsNullable = false)]
    public string Name { get; set; }

    [SugarColumn(ColumnName = "intro", IsNullable = false)]
    public string Introduction { get; set; }

    [SugarColumn(IsNullable = false, ColumnName = "is_del")]
    public short IsDeleted { get; set; }

    [SugarColumn(IsNullable = false, ColumnName = "create_time")]
    public DateTime CreateTime { get; set; }

    [SugarColumn(IsNullable = false, ColumnName = "update_time")]
    public DateTime UpdateTime { get; set; }

    private List<CrmebProductAttrValue>? _attrValues;

    [Navigate(NavigateType.OneToMany, nameof(CrmebProductAttrValue.ProductId))]
    public List<CrmebProductAttrValue>? AttrValues
    {
        get => _attrValues;
        set => _attrValues = value?.Where(x => x.IsDeleted == 0).ToList();
    }
}